package com.movie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.movie.bean.PlayRoom;
import com.movie.bean.vo.PageParams;
import com.movie.common.HttpResult;
import com.movie.service.PlayRoomService;
import com.movie.utils.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Liu Jiaquan
 * @Description
 * @date 2024/8/5 12:29
 */
@RestController
public class PlayRoomController {
    @Autowired
    private PlayRoomService playRoomService;

    @PostMapping("/saveRoom")
    public HttpResult<String> saveRoom(@RequestBody PlayRoom playRoom){
        playRoomService.save(playRoom);
        return HttpResult.success();
    }

    @PostMapping("/roomPage")
    public HttpResult<Page<PlayRoom>> page(@RequestBody PageParams pageParams){
        return HttpResult.success(playRoomService.page(pageParams));
    }

    @GetMapping("/roomList")
    public HttpResult<List<PlayRoom>> page(){
        return HttpResult.success(playRoomService.roomList());
    }

    @PostMapping("/updateRoomStatus")
    public HttpResult<String> updateRoomStatus(@RequestBody PlayRoom playRoom){
        playRoomService.updateStatus(playRoom);
        return HttpResult.success();
    }

}
